Skip to content

Conversation

@landaire
Copy link
Contributor

@landaire landaire commented Oct 16, 2025

See #7695 for motivation/background

One of the hottest paths in jj during checkout is can_create_file and create_parent_dirs. Both of these functions check to ensure that there aren't attempts to write to special directories (reject_reserved_existing) which is a fairly expensive check.

This change reduces file open/close syscalls by reusing file handles when possible.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@landaire landaire requested a review from a team as a code owner October 16, 2025 01:40
@landaire landaire changed the title lib: optimize file handle usage when calling into same_file lib: optimize file handle usage when calling into same_file during checkout Oct 16, 2025
@landaire landaire force-pushed the same_file_optimizations branch 2 times, most recently from 9799a44 to 65a2ed6 Compare October 17, 2025 03:25
@landaire landaire force-pushed the same_file_optimizations branch 3 times, most recently from b97edb2 to 9c07d3a Compare October 17, 2025 16:28
Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

checkout

See jj-vcs#7695 for motivation/background

One of the hottest paths in `jj` during checkout is `can_create_file`
and `create_parent_dirs`. Both of these functions check to ensure that
there aren't attempts to write to special directories
(`reject_reserved_existing`) which is a fairly expensive check.

This change reduces file open/close syscalls by reusing file handles
when possible.
@landaire landaire force-pushed the same_file_optimizations branch from 9c07d3a to d76e3b1 Compare October 18, 2025 16:41
@landaire landaire added this pull request to the merge queue Oct 24, 2025
Merged via the queue into jj-vcs:main with commit 6169175 Oct 24, 2025
29 checks passed
@landaire landaire deleted the same_file_optimizations branch October 24, 2025 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants